import java.sql.*;

public class TestJDBCUpdate {
	final static String DRIVER  = "oracle.jdbc.OracleDriver";
	final static String URL = "jdbc:oracle:thin:@localhost:1521:orcl";
	final static String USER = "hr";
	final static String PASSWORD = "hr";
	static Connection connection = null;
	static Statement stmt = null;
	public static void main(String[] args)  {
		
		try {
			//1 加载数据库驱动
			Class.forName(DRIVER);
			
			//2 建立连接
			connection = DriverManager.getConnection(URL, USER, PASSWORD);
			
			//3 获取Statement对象用来操作数据库
			stmt = connection.createStatement();
			
			//4 通过executeUpdate方法实现对数据库的操作
			String insertSQL = "insert into student values('小红', 15, 1534114141)";
			//返回受影响的行数
			int count = stmt.executeUpdate(insertSQL);
			System.out.println(count);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		
	}

}
